library(tidyverse)

# set replication folder as working directory
setwd("~replication")

load("data_genderedcost_attrition_mun.rdata")
load("data_genderedcost_email_party.rdata")

### FIGURE B1

ggplot(data=df_email_party, aes(x = parti_labels, y = mail_share)) +
  geom_col(color = "black", fill = "white") +
  geom_hline(yintercept = 0.837, linetype = "dashed") +
  ylab("Share of emails acquired") +
  xlab("") +
  theme_bw() +
  scale_y_continuous(labels = seq(0,1,0.2), breaks = seq(0,1,0.2)) +
  theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        panel.border = element_blank())

ggsave("figureB1.pdf", width = 8, height = 4)



### FIGURE B2

plot_map <- 
  plotDK::plotDK(data = df_attrition_mun,
                 id = "muni",
                 value = "mail_share",
                 plotlevel = "municipality",
                 show_borders = FALSE)

plot_map +
  scale_fill_viridis_c(option = "D", "Share of emails",
                       limits = c(0.5,1)) +
  theme(legend.position = c(0.85,0.8))

ggsave("plots/figureB2.pdf", height = 4, width = 8)

